function uiOp(value, row, index) {
    var htm = '';
    if (row.state == 'STARTED') {
        htm += '<button class="btn btn-danger btn-sm" type="button" onclick="doStop(\'' + row.id + '\')">禁用</button>';
    } else {
        htm += '<button class="btn btn-primary btn-sm" type="button" onclick="doStart(\'' + row.id + '\')">启用</button>';
    }
    if (row.config == true) {
        htm += '&nbsp;<button class="btn btn-info btn-sm" type="button" onclick="doConfig(\'' + row.id + '\')">配置</button>';
    }
    if (row.update != null) {
        htm += '&nbsp;<button class="btn btn-info btn-sm" type="button" onclick="doUpdate(\'' + row.id + '\',\'' + row.update.url + '\')">更新</button>';
    }
    return htm;
}

function uiReInstall(value, row, inde) {
    var htm = '&nbsp;<a class="jr-plugin-upload"><span server="reUpload?mid=' + getParam("mid") + '&pluginId=' + row.id + '" id="jrPick' + row.id + '" class="jr-upload">重新安装</span></a>';
    return htm;
}

function onLoadSuccess() {
    initUpload();
}

function doConfig(id) {
    win(contextPath + "/admin/plugin/" + id + "/pluginConfig?mid=" + getParam("mid"));
}

function doUpdate(id, url) {
    if (confirm("确定更新插件吗？")) {
        $.post("updatePlugin", {
            pluginId: id,
            url: url
        }, function (rs) {
            if (rs.rs == 'ok') {
                alert("插件更新成功！");
            } else {
                alert("插件更新失败！");
            }
            $("#easyui-datagrid-left").datagrid("reload");
        });
    }
}

function doStart(id) {
    $.post("start", {pluginId: id}, function (data) {
        $("#easyui-datagrid-left").datagrid("reload");
    });
}

function doStop(id) {
    if (confirm("确认禁用插件吗？禁用后插件功能将无法使用！")) {
        $.post("stop", {pluginId: id}, function (data) {
            $("#easyui-datagrid-left").datagrid("reload");
        });
    }
}

function jrtbMasterPickerUploadComplete() {
    $("#easyui-datagrid-left").datagrid("reload");
}